﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace RedFoxSpamKiller
{
  public class WebBrowserImpl: IWebBrowser
  {
    private WebBrowser browser;
    public WebBrowserImpl( WebBrowser browser )
    {
      this.browser = browser;
    }

    void IWebBrowser.navigate(string url)
    {
      browser.Navigate(url);
      browserIsReadey();
    }

    HtmlDocument IWebBrowser.getHtmlDocument()
    {
      return browser.Document;
    }

    string IWebBrowser.getDocumentText()
    {
      return browser.DocumentText;
    }

    private void browserIsReadey()
    {
      while (true)
      {
        System.Threading.Thread.Sleep(1000);
        Application.DoEvents();
        if (browser.ReadyState == WebBrowserReadyState.Complete)
        {
          break;
        }
      }
    }
  }
}
